package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.ReplyDTO;
import com.tianji.learning.domain.query.ReplyPageQuery;
import com.tianji.learning.domain.vo.ReplyVO;
import com.tianji.learning.service.IInteractionReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动问题的回答或评论 前端控制器
 * </p>
 *
 * @author waker
 * @since 2025-10-25
 */
@RestController
@RequestMapping("/replies")
@Api(tags = "用户端-回答或评论相关接口")
@RequiredArgsConstructor
public class InteractionReplyController {
    private final IInteractionReplyService replyService;

    /**
     * 9. 新增回答或评论(用户-管理端共用)
     *
     * @param replyDTO
     */
    @ApiOperation("新增回答或评论(用户-管理端共用)")
    @PostMapping
    public void saveReplyOrComment(@RequestBody ReplyDTO replyDTO) {
        replyService.saveReplyOrComment(replyDTO);
    }

    /**
     * 10. 分页查询回答或评论列表
     *
     * @param query
     * @return
     */
    @ApiOperation("用户端-分页查询回答或评论列表")
    @GetMapping("/page")
    public PageDTO<ReplyVO> pageQuery(ReplyPageQuery query) {
        // 1. 指定为学生查询，与管理端区分
        Boolean isStudent = true;
        return replyService.pageQuery(query, isStudent);
    }

}
